import React, { Component } from 'react';
import '../asserts/css/reg.css'
import {toRegister} from '../request/register'
class Reg extends Component {
    state={
          phone:"",
          nickname:"",
          password:"" 
    }
    //注册
    toRegisteruser()
    {
        let user = {...this.state}
        toRegister(user).then(res=>{
            if(res.code === 200)
            {
                this.props.history.push("/login")
            }
        })
        this.setState({phone:"",nickname:"",password:""});
    }
    render() {
        let {phone,nickname,password}  = this.state
        return (
            <>
                <div className="page-title">会员注册</div>
                <div className="container">
                    <div className="logo"></div>
                    <div className="form">
                        <div className="form-group">
                            <input type="text" placeholder="手机号" value={phone} onChange={(event)=>{this.setState({phone:event.target.value})}}/>
                        </div>
                        <div className="form-group">
                            <input type="text" placeholder="昵称" value={nickname}onChange={(event)=>{this.setState({nickname:event.target.value})}}/>
                        </div>
                        <div className="form-group">
                            <input type="password" placeholder="密码"  value={password} onChange={(event)=>{this.setState({password:event.target.value})}}/>
                        </div>
                        <div className="form-group">
                            <button className="btn-gray" type="button" onClick={this.toRegisteruser.bind(this)}>注册</button>
                        </div>
                    </div>
                </div>
            </>
        );
    }
}

export default Reg;